package hu.elte.inf.holiuml.gui;

import hu.elte.inf.holiuml.model.CommentNode;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 * @author Istvan Bozo
 */
public class CommentOptionsDialog extends OptionsDialog{
	JTextField commText;
	JPanel propPanel;
	CommentNode commentNode; 
	public CommentOptionsDialog(HoliUML parent, CommentNode commentNode){
		super(parent, "Comment Options");
		this.commentNode = commentNode;
		propPanel = new JPanel(new GridLayout(1,2));
		commText = new JTextField("Comment");
		if(commentNode != null){
			commText.setText(commentNode.getText());
		}
		propPanel.add(new JLabel("The text of the comment"));
		propPanel.add(commText);
		getContentPane().setLayout(new BorderLayout());
		getContentPane().add("North", propPanel);
		getContentPane().add("South", buttonPanel);
		setSize(new Dimension(450,150));
		setModalityType(ModalityType.APPLICATION_MODAL);
		setVisible(true);
	}
	
	public CommentNode createCommentNode(){
		CommentNode commentNode = new CommentNode();
		commentNode.setText(commText.getText());
		return commentNode;
	}

	public void modifyCommentNode(CommentNode commentNode){
		commentNode.setText(commText.getText());
	}
	
	protected boolean processOK(){
		return true;
	}
	protected void processCancel(){}
}
